package org.flower.web.servlet;

import org.flower.bean.Order;
import org.flower.entity.User;
import org.flower.service.OrderService;
import org.flower.service.impl.OrderServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(value = "/ViewDetailsServlet.shtml")
public class ViewDetailsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            //获取订单编号
            String id=request.getParameter("id");
            User user = (User)request.getSession().getAttribute("user");
            OrderService orderService = new OrderServiceImpl();
            List<Order> list=orderService.getById(user.getId(),id);
            if (list!=null){
                request.getSession().setAttribute("orderXiang",list);
                request.getRequestDispatcher("viewDetails.jsp").forward(request,response);
            }else{
                response.sendRedirect("index.jsp");
            }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
